﻿@{
    ViewBag.Title = "首页";
    Layout = "~/Views/Shared/_LayoutLogin.cshtml";
}
<div id="userLogin" class="login-inner">
    <div class="login-area-lay">
        <div class="login-area">
            <fieldset>
                <legend>管理员登录</legend>
                  @using (Ajax.BeginForm("Login", "Home", new AjaxOptions { HttpMethod = "post", OnBegin = "onBegin", OnSuccess = "onLogin" }))
                  {
                <div class="login-lay"><input type="text" class="login-text"  id="username" name="username" value=""  placeholder="请输入用户名" data-val-required="请输入用户名," data-val="true" /></div>
                <div class="login-lay"><input class="login-text" type="password" id="password" name="password" value="" placeholder="请输入密码" data-val-required="请输入密码" data-val="true"></div>
                      <div class="login-lay">
                          <input type="text" class="login-text" id="vcode" name="vcode" value=""  placeholder="请输入验证码" data-val-required="请输入验证码" data-val="true" />
                          <img id="valiCode" style="cursor: pointer;overflow:hidden;" src="/Home/GetValidateCode" alt="验证码" />
                      </div>
                      <div class="login-lay relative">
                         
                      </div>
                      <div class="login-btn">   
                       <div class="login-error-message">
                          <span data-valmsg-replace="true" data-valmsg-for="username" class="field-validation-valid"></span>
                          <span data-valmsg-replace="true" data-valmsg-for="password" class="field-validation-valid"></span>
                       </div>
                          <button type="submit" class="btn-primary" id ="loginsubmit">登 录</button>
                      </div>
                     
                  }
            </fieldset>
        </div>
    </div>
</div>

@section Scripts {
    <script type="text/javascript">
        function onBegin() {
            $('#loginsubmit').attr("disabled", true);
        }

        function onLogin(data) {
            $('#loginsubmit').attr("disabled", false);
            if (data.success) {
                window.location.href = data.data;
            } else {
                alert(data.data);
            }
        }

        $(document).ready(function() {
            $("#valiCode").bind("click", function() {
                this.src = "/Home/GetValidateCode?time=" + (new Date()).getTime();
            });
        });
    </script>
}    